﻿<%
'
' 底层函数，外部不要直接引用
' 要求：低耦合
' 函数命名：hu_myNameIsHu

'日期差距
'	@参数 d
' 		Day  d 日
' 		DayOfYear  y 日
' 		Hour  h 小时
' 		Minute  n  分钟
' 		Month  m 月
' 		Quarter  q  季度
' 		Second  s 秒钟
' 		Weekday  w 周
' 		WeekOfYear  ww  日历周
' 		Year  yyyy 年
Function hu_dateDiff(day, d)
	day = Trim(day)
	If Not isDate(day) Then Exit Function
	hu_dateDiff = DateDiff(d,time_date,Cdate(day))
End Function

'生成图片
Function hu_image(src, alt, title, ex)
	hu_image = "<img src='"&src&"' alt='"&alt&"' "&ex&"/>"
End Function

'生成链接
Function hu_anchor(src, name, title, ex)
	hu_anchor = "<a href='"&src&"' "&ex&">"&name&"</a>"
End Function

'改写IsNull
Function hu_isNull(str)
	hu_isNull = False
	Select Case VarType(str)
	Case vbEmpty, vbNull
		hu_isNull = True : Exit Function
	Case vbString
		If str="" Then hu_isNull = True : Exit Function
	Case vbObject
		If TypeName(str)="Nothing" Or TypeName(str)="Empty" Then hu_isNull = True : Exit Function
	Case vbArray,8194,8204,8209
		If Ubound(str)=-1 Then hu_isNull = True : Exit Function
	End Select
End Function

'格式化时间
Function hu_dateFormat(str, style)
	If Not IsDate(str) Then Exit Function
	Dim tmp
	tmp = style
	tmp = Replace(tmp, "y", Year(str), 1, -1, 1)
	tmp = Replace(tmp, "m", Month(str), 1, -1, 1)
	tmp = Replace(tmp, "d", Day(str), 1, -1, 1)
	tmp = Replace(tmp, "h", Right("0"&Hour(str),2), 1, -1, 1)
	tmp = Replace(tmp, "i", Right("0"&Minute(str),2), 1, -1, 1)
	tmp = Replace(tmp, "s", Right("0"&Second(str),2), 1, -1, 1)
	hu_dateFormat = tmp
End Function

'字符过滤函数
Function hu_changeWord(str, badStandard, changedWord)
	Dim s,i
	s=split(badStandard,",")
	For i=Lbound(s) To ubound(s)
	str=replace(str,s(i),changedWord)
	Next
	hu_changeWord=str
End Function

'替换bug字符 - 展现
Function hu_forShow(str)
	If hu_isNull(str) Then Exit Function
	str=hu_decode(str)
	str=Replace(str,"&#","_74_asp_")
	str=Replace(str,"&amp;","_74_amp_")
	str=Replace(str,"&","&amp;")
	str=Replace(str,"_74_amp_","&amp;")
	str=Replace(str,"<","&lt;")
	str=Replace(str,">","&gt;")
	str=Replace(str,"'","&apos;")
	str=Replace(str,"""","&quot;")
	str=Replace(str,"_74_asp_","&#")
	If hu_style Then hu_forShow=str:Exit Function
	str=Replace(str,"$$","_74_my_")
	str=Replace(str,"$","$$")
	str=Replace(str,"_74_my_","$$")
	hu_forShow=str
End Function

'符号写入数据库
Function hu_common(str)
	If hu_isNull(str) Then Exit Function
	str=Replace(str,"'","''")
	' str=Replace(str,vbnewline,"\\")
	' str=Replace(str,VbCrLf,"\\")
	hu_common=str
End Function

'过滤用户数据
Function hu_encode(str)
	If hu_isNull(str) Then Exit Function
	str=Replace(str,"74hu_","_74_hu_",1,-1,1)'数据库表前缀替换
	str=Replace(str,"法轮","**")'国内服务器拒绝写入
	hu_encode=str
End Function

'还原用户数据
Function hu_decode(str)
	If hu_isNull(str) Then Exit Function
	str=Replace(str,"_74_hu_","74hu_")
	hu_decode=str
End Function

'用于搜索,登陆过滤等
Function hu_filter(str)
	If hu_isNull(str) Then Exit Function
	str=Replace(str,"'","",1,-1,1)
	str=Replace(str,"74hu_","",1,-1,1)
	str=Replace(str,"法轮","")'国内服务器拒绝写入
	hu_filter=str
End Function

'改写left
Function hu_left(str, strlen)
	If hu_isNull(str) Then hu_left = "":Exit Function
	Dim t, c, i, strTemp
	str = Replace(Replace(Replace(Replace(Replace(str,"&nbsp;"," "),"&quot;",Chr(34)),"&gt;",">"),"&lt;","<"),"&apos;","'")
	t = 0
	strTemp = str
	strlen = CLng(strlen)
	For i = 1 To Len(str)
		c = Abs(Asc(Mid(str, i, 1)))
		If c = 1 Then
			t = t + 1
		Else
			t = t + 0.6'这里的0.6可酌情修改，考虑字符占位不同
		End If
		If t >= strlen Then strTemp = Left(str, i):Exit For
	Next
	If strTemp <> str Then strTemp = strTemp & ".."
	hu_left = Replace(Replace(Replace(Replace(strTemp,"'","&apos;"),Chr(34),""""),">","&gt;"),"<","&lt;")
End Function

'产生随机字母数字
Function hu_randomize()
	Dim c_,id_,tmp_,i_,len_
	c_="a,A,1,b,B,2,c,C,3,d,D,4,e,E,5,f,F,6,g,G,7,h,H,8,i,I,9,j,J,0,k,K,l,L,m,M,n,N,o,O,p,P,q,Q,r,R,s,S,t,T,u,U,v,V,w,W,x,X,y,Y,z,Z"
	id_=split(c_,",")
	len_=UBound(id_)+1
	for i_=1 to 10
		tmp_=id_(int(rnd()*len_))&tmp_
	Next
	hu_randomize=tmp_
End Function

'判断字符串是否全英文
Function hu_isLetters(str)
	Dim lstr,i,t_
	If hu_isNull(str) Then hu_isLetters = False:Exit Function
	lstr = LCase(str)
	For i = 1 To Len(lstr)
		t_=Asc(Mid(lstr, i, 1))
		If t_<97 Or t_>122  Then hu_isLetters = False:Exit Function
	Next
	hu_isLetters = True
End Function

'随机显示字符
Function hu_rndObj(str,pattern)
	str=Split(str,pattern)
	hu_rndObj=str(int(rnd()*(UBound(str)+1)))
End Function

'检查组件是否已经安装
Function hu_isObjInstalled(str)
	Dim xObj
	On Error Resume Next
	hu_isObjInstalled = False
	Err.Clear()
	Set xObj = Server.CreateObject(str)
	If Err.number = 0 Or Err.number = -2147352567 Then hu_isObjInstalled = True
	Set xObj = Nothing
	Err.Clear()
End Function

'检查目录写入权限
Function hu_isDirWritable(dir)
	Dim fso,tmp
	On Error Resume Next
	dir = Server.MapPath(dir)
	tmp = dir & "\_dir_writable_test.log"
	Err.Clear()
	Set fso=Server.CreateObject("Scripting.FileSystemObject")
	fso.CreateTextFile(tmp)
	If Err.number<>0 then
		hu_isDirWritable=False
	Else
		hu_isDirWritable=True
	End If
	fso.DeleteFile(tmp)
	Set fso=Nothing
	Err.Clear()
End Function

'检查是否纯数字
Function hu_isNumeric(str)
	If hu_isNull(str)=False And IsNumeric(str) Then hu_isNumeric=True: Exit Function
	hu_isNumeric=False
End Function

'检查是否纯数字,用于快速检查
Function hu_isNumber(str)
	If str<>"" And IsNumeric(str) Then hu_isNumber=True: Exit Function
	hu_isNumber=False
End Function

'生成wap1表单
Public Function hu_getForm1(formarray)
	If ifSpider Then Exit Function'屏蔽爬虫
	dim str,strEnd,i,j,tempArr,tempArray,temp,temp1,temp2,time_
	formStr = Split(formarray(0), "||")
	str=""
	time_=time_r
	strEnd = "<anchor>"&formStr(2)&"<go href="""&formStr(0)&""" method="""&formStr(1)&""">"
	If UBound(formStr)>2 Then str = str & formStr(3)
	for i=1 to UBound(formarray)
		tempArr=Split(formarray(i), "||")
		temp = UBound(tempArr)
		If temp < 0 Then hu_getForm1 = str & strEnd & "</go></anchor><br/>" : Exit Function
		Select Case tempArr(0)
			Case "input"
				for j=1 to temp-1
					tempArray=Split(tempArr(j), "$$")
					temp1 = tempArray(0)
					If UBound(tempArray) < 2 Then
						temp2 = ""
					Else
						temp2 = " size=""" & tempArray(2) & """"
						If UBound(tempArray) > 2 Then temp2 = temp2 & " maxlength="""&tempArray(3)&""""
					End If
					str = str & "<input name="""&temp1 &time_&""" value="""&tempArray(1)&""""&temp2&"/>"
					strEnd = strEnd & "<postfield name="""&temp1&""" value=""$("&temp1&time_&")""/>"
				next
				str = str & tempArr(j)
			Case "area"
				for j=1 to temp-1
					tempArray=Split(tempArr(j), "$$")
					temp1 = tempArray(0)
					If UBound(tempArray) < 2 Then
						temp2 = ""
					Else
						temp2 = " size=""" & tempArray(2) & """"
						If UBound(tempArray) > 2 Then temp2 = temp2 & " maxlength="""&tempArray(3)&""""
					End If
					str = str & "<input name="""&temp1 &time_&""" value="""&tempArray(1)&""""&temp2&"/>"
					strEnd = strEnd & "<postfield name="""&temp1&""" value=""$("&temp1&time_&")""/>"
				next
				str = str & tempArr(j)
			Case "select"
				tempArray=Split(tempArr(1), "$$")
				temp1=tempArray(0)
				str = str & "<select name="""&temp1 & time_&""" value="""&tempArray(1)&""">"
				for j=2 to temp-1
					tempArray=Split(tempArr(j), "$$")
					str = str & "<option value="""&tempArray(0)&""">"&tempArray(1)&"</option>"
				next
				str = str & "</select>" & tempArr(j)
				strEnd = strEnd & "<postfield name="""&temp1&""" value=""$("&temp1&time_&")""/>"
			Case "hidden"
				for j=1 to temp-1
					tempArray=Split(tempArr(j), "$$")
					strEnd = strEnd & "<postfield name="""&tempArray(0)&""" value="""&tempArray(1)&"""/>"
				next
				str = str & tempArr(j)
		End Select
	next
	hu_getForm1 = str & strEnd & "</go></anchor>"
End Function

'生成wap2表单
Public Function hu_getForm2(formarray)
	If ifSpider Then Exit Function'屏蔽爬虫
	dim str,strEnd,i,j,tempArr,tempArray,temp,temp1,temp2
	formStr = Split(formarray(0), "||")
	str = "<form action="""&formStr(0)&""" method="""&formStr(1)&""">"
	strEnd = "<input type=""submit"" value="""&formStr(2)&"""/></form>"
	If UBound(formStr)>2 Then str = str & formStr(3)
	for i=1 to UBound(formarray)
		tempArr=Split(formarray(i), "||")
		temp = UBound(tempArr)
		If temp < 0 Then hu_getForm2 = str & strEnd : Exit Function
		Select Case tempArr(0)
			Case "input"
				for j=1 to temp-1
					tempArray=Split(tempArr(j), "$$")
					If UBound(tempArray) < 2 Then
						temp1 = ""
					Else
						temp1 = " style=""width:" & tempArray(2)*9 & "px;"""
						If UBound(tempArray) > 2 Then temp1 = temp1 & " maxlength="""&tempArray(3)&""""
					End If
					str = str & "<input type=""text"" name="""&tempArray(0)&""" value="""&tempArray(1)&""""&temp1&"/>"
				next
				str = str & tempArr(j)
			Case "area"
				for j=1 to temp-1
					tempArray=Split(tempArr(j), "$$")
					If UBound(tempArray) < 2 Then
						temp1 = ""
					Else
						temp1 = " cols=""" & tempArray(2) & """"
						' 字数限制失效
						' If UBound(tempArray) > 2 Then temp1 = temp1 & " maxlength="""&tempArray(3)&""""
					End If
					str = str & "<textarea name="""&tempArray(0)&""" "&temp1&" rows=""8"">"&tempArray(1)&"</textarea>"
				next
				str = str & tempArr(j)
			Case "select"
				tempArray=Split(tempArr(1), "$$")
				temp1 = tempArray(1)
				str = str & "<select name="""&tempArray(0)&""">"
				for j=2 to temp-1
					tempArray=Split(tempArr(j), "$$")
					temp2 = tempArray(0)
					str = str & "<option value="""&temp2&""""
					If temp1=temp2 Then str = str & " selected=""selected"""
					str = str & ">"&tempArray(1)&"</option>"
				next
				str = str & "</select>" & tempArr(j)
			Case "hidden"
				for j=1 to temp-1
					tempArray=Split(tempArr(j), "$$")
					str = str & "<input type=""hidden"" name="""&tempArray(0)&""" value="""&tempArray(1)&"""/>"
				next
				str = str & tempArr(j)
		End Select
	next
	hu_getForm2 = str & strEnd
End Function

'为何写这个类?
'她是一个外部接口
'实现方法的封装,数据获取,数据对象处理,兼容性处理
'避免了需要对wap1和wap2分别开发

'核心类
Class huClass
	Private ver_			'版本号
	Private sid_			'会话内容
	Private sidKey_			'会话名称
	Private fso_			'文件操作对象
	Private conn_			'数据库对象
	' Private html_			'网页内容
	Private title_			'网页标题
	Private description_	'网页描述
	Private keyword_		'网页关键词
	Private head_			'网页头部
	Private body_			'网页主体
	Private count_			'数据库查询次数
	Private debug_			'开发模式
	Private logPath_		'日志目录(本地路径,用于生成日志)
	Private curPath_		'当前目录(网站地址,用于生成链接)
	Private lastExec_		'最近一次查询耗时
	Private connExec_		'总查询耗时
	Private recordsAffected_'最近一次查询影响记录数
	'Private connTimeout_	'连接超时(用于记录超时,改进查询)
	Private style_			'样式控制
	Private styleKey_		'样式控制Key(用于链接)
	'Private config_		'配置控制
	Private autoRedirect_	'重定向链接
	Private autoTime_		'重定向时间(s)
	Private isMobile_		'用户浏览器
	Private buffer_			'服务器缓冲
	Private alive_			'服务器Keep-alive
	Private css_			'wap2.0 css样式
	Private align_			'wap1.0 对齐方式

	Private end_			'结束标识

	'构造函数
	Private Sub Class_Initialize
		initProperty()
	End Sub

	'析构函数
	Private Sub Class_Terminate
		initPrint()
	End Sub

	'版本
	Public Property Get Ver
		Ver = ver_
	End Property

	'数据库查询次数
	Public Property Get ConnCount
		ConnCount = count_
	End Property

	'系统执行时间
	Public Property Get ExecTime
		ExecTime = FormatNumber((Timer-time_start), 3, True)
	End Property

	'最近一次查询耗时
	Public Property Get LastTime
		LastTime = FormatNumber((lastExec_), 3, True)
	End Property

	'数据库查询总耗时
	Public Property Get ConnTime
		ConnTime = FormatNumber((connExec_), 3, True)
	End Property

	'获取开发模式
	Public Property Get Debug
		Debug = debug_
	End Property

	'获取Sid会话内容
	Public Property Get Sid
		Sid = sid_
	End Property

	'设置sid会话内容
	Public Property Let Sid(str)
		'为提高效率,不检测意外赋值
		sid_ = str
	End Property

	'获取Sid会话内容
	Public Property Get SidKey
		SidKey = sidKey_
	End Property

	'设置sid会话名称
	Public Property Let SidKey(str)
		'为提高效率,不检测意外赋值
		sidKey_ = str
	End Property

	'设置开发模式
	Public Property Let Debug(bool)
		If bool = True Then
			debug_ = True
			Set fso_ = CreateObject("Scripting.FileSystemObject")
		Else
			debug_ = False
			Set fso_ = Nothing
		End If
	End Property

	'获取日志目录
	Public Property Get LogPath
		LogPath = logPath_
	End Property

	'设置开发模式
	Public Property Let LogPath(path)
		path = Server.MapPath(path)
		If TypeName(fso_) = "FileSystemObject" Then
			If fso_.FolderExists(path) Then logPath_ = path
		Else
			logPath_ = ""
		End If
	End Property
	
	'获取当前目录
	Public Property Get CurPath
		CurPath = curPath_
	End Property

	'设置开发模式
	Public Property Let CurPath(path)
		curPath_ = path
	End Property

	'获取网站样式
	Public Property Get Style
		Style = style_
	End Property

	'设置网站样式
	Public Property Let Style(num)
		If num<>1 Or num<>2 Then num=3
		style_ = num
	End Property

	'获取网站样式key
	Public Property Get StyleKey
		StyleKey = styleKey_
	End Property

	'设置网站样式key
	Public Property Let StyleKey(str)
		'为提高效率,不检测意外赋值
		styleKey_ = str
	End Property

	'获取网站css样式
	Public Property Get Css
		Css = css_
	End Property

	'设置网站css样式
	Public Property Let Css(str)
		'为提高效率,不检测意外赋值
		css_ = str
	End Property

	'获取网站对齐样式
	Public Property Get Align
		Align = align_
	End Property

	'设置网站对齐样式
	Public Property Let Align(str)
		'为提高效率,不检测意外赋值
		align_ = str
	End Property

	'获取服务器Keep-alive
	Public Property Get Alive
		Alive = alive_
	End Property

	'设置服务器Keep-alive
	Public Property Let Alive(bool)
		'为提高效率,不检测意外赋值
		alive_ = bool
	End Property

	'获取重定向设置
	Public Property Get AutoRedirect
		AutoRedirect = autoRedirect_
	End Property

	'修改重定向设置
	Public Property Let AutoRedirect(url)
		'为提高效率,不检测意外赋值
		autoRedirect_ = url
	End Property

	'获取重定向时间
	Public Property Get AutoTime
		AutoTime = autoTime_
	End Property

	'修改重定向时间
	Public Property Let AutoTime(num)
		'为提高效率,不检测意外赋值
		autoTime_ = num
	End Property

	'获取网页标题
	Public Property Get Title
		Title = title_
	End Property

	'修改网页标题
	Public Property Let Title(str)
		'为提高效率,不检测意外赋值
		title_ = str
	End Property

	'获取网页描述
	Public Property Get Description
		Description = description_
	End Property

	'修改网页描述
	Public Property Let Description(str)
		'为提高效率,不检测意外赋值
		description_ = str
	End Property

	'获取网页关键词
	Public Property Get Keyword
		Keyword = keyword_
	End Property

	'修改网页关键词
	Public Property Let Keyword(str)
		'为提高效率,不检测意外赋值
		keyword_ = str
	End Property

	'获取网页头部
	Public Property Get Head
		Head = head_
	End Property

	'缓存网页头部,用于补充关键字
	Public Property Let Head(str)
		'为提高效率,不检测意外赋值
		head_ = head_ & str
	End Property

	'获取网页主体
	Public Property Get Body
		Body = body_
	End Property

	'缓存网页主体
	Public Property Let Body(str)
		'为提高效率,不检测意外赋值
		body_ = body_ & str
	End Property

	'获取数据库对象
	Public Property Get Db
		Db = conn_
	End Property

	'实例数据对象
	Public Property Let Db(str)
		'为提高效率,不检测意外赋值
		conn_.open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database PASSWORD=;Data Source="&Server.MapPath(""&str&"")
	End Property

	
	'初始化属性
	Private Sub InitProperty
		ver_ = 1
		count_ = 0
		lastExec_ = 0
		connExec_ = 0
		style_ = 1
		debug_ = False '关闭开发模式
		logPath_ = ""
		autoRedirect_ = "" '关闭重定向
		autoTime_ = 2 '重定向时间
		description_ = ""
		keyword_ = ""
		title_ = ""
		head_ = ""
		body_ = ""
		buffer_ = True'服务器缓冲
		alive_ = True'服务器Keep-alive
		Set conn_=Server.CreateObject("ADODB.Connection")
	End Sub

	Private Sub InitResponse
		'设置缓冲等
		If buffer_ = True Then
			With Response
			.Buffer = True
			.Expires = 0
			.ExpiresAbsolute = time_now - 1
			.CacheControl = "no-cache"
			.AddHeader "Expires", time_date
			.AddHeader "Pragma","no-cache"
			.AddHeader "Cache-Control","private, no-cache, must-revalidate"
			End With
		End If
		'减少服务器压力
		If alive_ = False Then
			Session.Abandon
		End If

	End Sub

	Private Sub initPrint
		If end_ <> True Then Print()
	End Sub

	'释放对象,回收内存
	Private Sub ReleaseObject
		end_ = True
		conn_.close
		Set conn_ = Nothing
		Set fso_ = Nothing
	End Sub

	'输出
	Public Sub Write(str)
		Response.Write str
	End Sub

	'页面跳转
	Public Sub Redirect(url)
		ReleaseObject()
		Response.Redirect url
	End Sub

	'输出缓存
	Public Sub Print
		ReleaseObject()
		InitResponse()
		Dim html,cacheHtml
		html = "<?xml version=""1.0"" encoding=""utf-8""?>"
		cacheHtml = "<meta http-equiv=""Cache-Control"" content=""no-cache""/><meta http-equiv=""Cache-Control"" content=""max-age=0""/>"
		description_="<meta name=""description"" content="""& description_ &"""/>"
		keyword_="<meta name=""keywords"" content="""&keyword_&"""/>"
		With Response
		Select Case style_
		Case 2,3
			.ContentType = "text/html; charset=utf-8"
			html = html & "<!DOCTYPE html PUBLIC ""-//WAPFORUM//DTD XHTML Mobile 1.0//EN"" ""http://www.wapforum.org/DTD/xhtml-mobile10.dtd"">" &_
				"<html xmlns=""http://www.w3.org/1999/xhtml""><head><meta http-equiv=""Content-Type"" content=""text/html;charset=utf-8""/>"&_
				cacheHtml &"<meta name=""Author"" content=""74hu.cn""/>"& description_ & keyword_ &_
				"<title>"& title_ &"</title><style type=""text/css"">"& css_ &"</style>"
			If autoRedirect_ <> "" Then html = html & "<meta http-equiv=""refresh"" content="""&autoTime_&";URL="&autoRedirect_&""" />"
			html = html & head_ & "</head><body><div class=""main""><a id=""top"" name=""top""></a>"&body_&"</div></body></html>"
		Case Else
			.ContentType = "text/vnd.wap.wml; charset=utf-8"
			html = html & "<!DOCTYPE wml PUBLIC ""-//WAPFORUM//DTD WML 1.1//EN"" ""http://www.wapforum.org/DTD/wml_1.1.xml""><wml><head>"&_
				cacheHtml& "<meta name=""Author"" content=""74hu.cn""/>"& description_ & keyword_& head_&"</head>"
			If autoRedirect_ = "" Then
				html = html & "<card id=""main"" title="""&title_&""">"
			Else
				html = html & "<card id =""main"" title="""&title&""" ontimer="""&autoRedirect_&"""><timer value="""&autoTime_*10&"""/>"
			End If
			html = html & "<p align="""&align_&""">"&body_&"</p></card></wml>"
		End Select
		.Write html
		.End
		End With
	End Sub

	'执行SQL语句
	Public Function Conn(sql)
		' log("error:"&sql)
		If debug_=True Then lastExec_ = Timer
		Dim cmd : Set cmd = Server.CreateObject("ADODB.Command")
		With cmd
			.ActiveConnection = conn_
			.CommandType = &H0001' adCmdText：表示处理的是一个SQL语句
			.CommandText = sql
			'.CommandTimeout = N' 超时时间,默认30秒 N：需要设置的秒数
			Set Conn = .Execute (recordsAffected_)
			' If Err.Number<>0 Then log("Error:"&sql)
			'数据库未升级这里会报错
			'TODO select 等考虑 ReadOnly
		End With
		Set cmd = Nothing
		If debug_=True Then'开发状态下记录查询
			lastExec_ = Timer - lastExec_
			connExec_ = connExec_ + lastExec_
			count_ = count_ + 1
			Log("[SQL:"&FormatNumber((lastExec_), 3, True)&"]"&sql)
		End If
	End Function

	'写日志
	Public Function Log(str)
		Dim file,f
		If logPath_<>"" Then
			file = logPath_&"\"&time_date&".log"
			If Not fso_.FileExists(file) Then Call fso_.CreateTextFile(file,True)
			Set f = fso_.OpenTextFile(file, 8)
			f.Write "["&time_now&"] "&str&chr(13)&chr(10)
			f.Close
			Set f=Nothing
		End If
	End Function

	'获取get数据
	Public Function QueryString(str)
		QueryString=Trim(Request.QueryString(str))
	End Function

	'获取post数据
	Public Function Form(str)
		Form=Trim(Request.Form(str))
	End Function

	'获取数据
	Public Function getData(str)
		Dim tmp: tmp=Trim(Request.QueryString(str))
		If tmp="" Then tmp=Trim(Request.Form(str))
		getData=tmp
	End Function

	'获取字符数据(防注入)
	Public Function getD(str, def)
		Dim tmp: tmp=getData(str)
		If tmp="" Then getD=def:Exit Function
		getD=hu_encode(tmp)
	End Function

	'获取数字数据(防注入)
	Public Function getN(str, def)
		Dim tmp: tmp=getData(str)
		If tmp="" Or IsNumeric(tmp)=False Then getN=def:Exit Function
		getN=tmp
	End Function

	'构造链接
	Public Function Url(url_, name)
		'判断网站是站内或站外,站内要加上防断线标识
		Dim siteUrl:siteUrl = "http://" & http_server
		If InStr(url_, "://")=0 Then
			url_ = curPath_ & urlAddSessionSign(url_)
		Elseif left(url_, Len(siteUrl)) = siteUrl Then
			url_ = urlAddSessionSign(url_)
		End If
		Url = hu_anchor(url_, name, name, "")
	End Function
	
	'站内链接要加上防断线标识,及强制浏览器更新缓存
	Private Function urlAddSessionSign(url_)
		If InStr(url_, "?")>0 Then
			url_ = url_ &"&amp;"
		Else
			url_ = url_ &"?"
		End If
		urlAddSessionSign = url_ & sidKey_ & "=" & sid_ &"&amp;tt="&time_r
	End Function
	
	'构造图片
	Public Function Img(url, name)
		Img = hu_image(url, name, "", "")
	End Function

	'构造表单
	Public Function getForm(formArray)
		Select Case style_
		Case 2,3
			getForm = hu_getForm2(formArray)
		Case Else
			getForm = hu_getForm1(formArray)
		End Select
	End Function
	
End Class
%>